<?php
	$fName = $_POST['fName'];
	$lName = $_POST['lName'];
	$email = $_POST['email'];
	$gender = $_POST['gender'];
	if(strlen($fName) > 32 || strlen($lName) > 32 ||strlen($fName) < 1 || strlen($lName) < 1)
	{
		$error = "The max length of inputs is 32 characters and the minimum is 1.";
		$url = "index.php?error=".$error;
		header("Location:".$url);
		die;
	}
	if (isset($_POST['grad']))
	{
		$grad="yes";
	} else
	{
		$grad="no";
	}

$con=mysqli_connect("localhost","n00659426","n00659426","n00659426");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

$update="update persons set FirstName=?, LastName=?, Gender=?, Graduate=? where ";
$update=$update."Email=?";
$q=$con->prepare($update);
$q->bind_param('sssss', $fName, $lName, $gender, $grad, $email);
$q->execute();

$con->close();
$url="index.php";
header("Location: ".$url);
die;
